package mail;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;

/**
 * Klasse repraesentiert das Objekt Email
 * 
 * @author Michi
 * 
 */
public class Mail {

	/**
	 * Member Data
	 */
	private String from = "";
	private LinkedList<String> to = new LinkedList<String>();
	private LinkedList<String> cc = new LinkedList<String>();
	private LinkedList<String> bcc = new LinkedList<String>();
	private String betreff = "";
	private String text = "";
	private String textType = "";
	private Date sentDate;
	private int mailNumber;
	private int hash;
	private ArrayList<File> attachments;

	// Getter und Setter Area

	public LinkedList<String> getCc() {
		return cc;
	}

	public void setCc(LinkedList<String> cc) {
		this.cc = cc;
	}

	public LinkedList<String> getBcc() {
		return bcc;
	}

	public void setBcc(LinkedList<String> bcc) {
		this.bcc = bcc;
	}

	public int getHash() {
		return hash;
	}

	public void setHash(int hash) {
		this.hash = hash;
	}

	public int getMailNumber() {
		return mailNumber;
	}

	public void setMailNumber(int mailNumber) {
		this.mailNumber = mailNumber;
	}

	public Date getSentDate() {
		return sentDate;
	}

	public void setSentDate(Date sentDate) {
		this.sentDate = sentDate;
	}

	public String getTextType() {
		return textType;
	}

	public void setTextType(String textType) {
		this.textType = textType;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public LinkedList<String> getTo() {
		return to;
	}

	public void setTo(LinkedList<String> to) {
		this.to = to;
	}

	public String getBetreff() {
		return betreff;
	}

	public void setBetreff(String betreff) {
		this.betreff = betreff;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public void addRec(String email) {
		to.add(email);
	}

	public void removeRec(int x) {
		to.remove(x);
	}

	// Mtehods Area

	/**
	 * Funktion gibt eine Email mit all ihren Daten zurueck
	 */
	public String toString() {
		String s = "";

		s = s + "Von: " + getFrom() + "\n" + "An: " + getToString() + "\n"
				+ "Betreff: " + getBetreff() + "\n" + "Empfangen am: "
				+ getSentDate().toString() + "\n" + "Message Number: "
				+ getMailNumber() + "\n" + "Hash: " + getHash() + "\n" + "\n"
				+ getText();

		return s;
	}

	/**
	 * Funktion gibt alle Emails mit ihren jeweiligen Daten zurueck
	 * 
	 * @return String welcher alle Emails enthaelt
	 */
	public String getToString() {
		String str = "";

		for (int i = 0; i < to.size(); i++) {
			if (i < to.size() - 1) {
				str = str + to.get(i) + ", ";
			} else {
				str = str + to.get(i);
			}
		}

		return str;
	}

	public ArrayList<File> getAttachments() {
		return attachments;
	}

	public void setAttachments(ArrayList<File> attachments) {
		this.attachments = attachments;
	}
}
